Skip to content

feat: add support for nullable parameters in API calls in python #1098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

ChiragAgg5k
Copy link
Member

What does this PR do?

currently python sdk filters out all None values from api requests. but attributes like default can be nullable, and hence should not be filtered out

Test Plan

Screenshot 2025-07-01 at 6 17 30 PM

Related PRs and Issues

Have you read the Contributing Guidelines on issues?

yes.

@ChiragAgg5k ChiragAgg5k requested a review from Copilot July 1, 2025 12:48
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the Python SDK’s request builder so that parameters marked as nullable in the API schema aren’t dropped when they’re explicitly set to None.

  • Added a nullable_params argument to Client.call and updated the filtering logic
  • Updated the low-level request template to pass nullable parameters through
  • Populated nullable_params in the parameter-gathering template
Comments suppressed due to low confidence (3)

templates/python/package/client.py.twig:52

  • The new nullable_params argument should be documented (e.g., in a docstring or comment) to explain that it is a list of parameter names that should not have their None values filtered out.
    def call(self, method, path='', headers=None, params=None, response_type='json', nullable_params=None):

templates/python/base/requests/api.twig:8

  • Passing nullable_params as a positional argument can shift the meaning of subsequent positional parameters; consider using nullable_params=nullable_params as a named argument to avoid breaking callers if the signature changes.
        }, api_params, nullable_params{% if method.type == 'webAuth' %}, response_type='location'{% endif %})

templates/python/package/client.py.twig:63

  • We should add or update unit tests to cover the new behavior: verify that parameters listed in nullable_params remain in the request payload even when their value is None.
        params = {k: v for k, v in params.items() if v is not None or k in nullable_params}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant